package com.yanqu.road.server.cmd.activity.hsisland;

import com.yanqu.road.exception.BusinessException;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.HsIslandProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.command.CmdApi;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.hsisland.HsIslandActivityModule;
import com.yanqu.road.server.protocol.Protocol;

@CmdApi(reqMsg = HsIslandProto.HsIslandMoveReqMsg.class, respMsg = HsIslandProto.HsIslandMoveRespMsg.class)
@Cmd(code = Protocol.S_HS_ISLAND_MOVE,desc = "海神岛-移动")
public class HsIslandMoveCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        HsIslandProto.HsIslandMoveReqMsg reqMsg = HsIslandProto.HsIslandMoveReqMsg.parseFrom(packet.getBytes());
        try {
            player.getModule(HsIslandActivityModule.class).move(reqMsg);
        } catch (BusinessException e) {
            HsIslandProto.HsIslandMoveRespMsg.Builder respMsg = HsIslandProto.HsIslandMoveRespMsg.newBuilder();
            respMsg.setRet(e.getCode());
            player.sendPacket(Protocol.U_HS_ISLAND_MOVE, respMsg);
        }
    }

    @Override
    public void sendData(GamePlayer player) {}
}
